import { getSampleList,getColumns  } from '@/axios/api'
import { sampleSize } from 'lodash'
export default{
  created() {
    getSampleList().then(res => {
      this.samples = res.data.sampleList
    })
  },
  data(){
    return {
      current:false,
      pageSize:10,
      samplId: null,//收藏表选中的id
      samples:[],
      chooseVarName:[],
      searchLoading:false,
      searchChange:this._debounce(({target:{_value:value}}) => {
        this.searchLoading = true
        if(!value) this.columns = this.allcolumns
        else {
          this.columns = this.allcolumns.filter(e=>
            e.toLowerCase().indexOf(value.toLowerCase()) >= 0
          )
        }
        setTimeout(()=>{this.searchLoading = false}, 200);
      },1000),
      columns:[],
      allcolumns:[],
      all_num:0,
      selectsample:(item) => {
        const { id,fileInfo,confInfo } = item
        this.samplId = id
        this.current = false
        this.varName = []
        const total = fileInfo?  /x(.*)]/.exec(fileInfo.total)[1]:confInfo.chooseNum
        this.all_num = total? total:'读取异常'
        // debugger
        getColumns({id}).then(e=>{
          const { columns } = e.data
          this.allcolumns = Object.freeze(columns)
          this.searchValue = ''
          this.searchLoading = false
          this.columns = columns
        })
      },
      subType: '0',
      subNumber: 10,
      selectFilter:this._debounce(input => {
        if(!input) this.columns = []
        else {
          this.columns = this.allcolumns.filter(e=>
            e.toLowerCase().indexOf(input.toLowerCase()) >= 0
          )
        }
      },1000),
    }
  },
}